import java.io.IOException;
import java.net.URL;
import java.util.ArrayList;
import java.util.List;


public class MyClassify {
	
	public static Hierarchy H=new Hierarchy();
	
	public List<String> myClass(Category C, String url, int coverage, double specifity, double pspec ){
		
		List<String> result=new ArrayList<String> ();
		if(C.children.isEmpty()){
			result.add(C.name);
			return result;
		}
		else{
			int totalCount=0;
			
				for(Category D:C.children){
					
			        try {
						totalCount+= H.calCoverage(D, url);
						
					} catch (Exception e) {
						System.out.println("MyClassify.H");
					}
			
				}
				for(Category D:C.children){
					H.calSpecifity(D, url, pspec,totalCount);
				}
				
				for(Category D:C.children){
					
					if(D.eSpecifify>specifity && D.eCoverage>coverage){
						
						result.addAll(myClass(D, url,coverage, specifity,C.eSpecifify ));
					}
				}
				if(result.isEmpty()){
					result.add(C.name);
				}
				
				return result;
				
		}
	
	}
	public static void main(String args[]) throws IOException{
		
		Hierarchy H=new Hierarchy();
		H.buildProbes();
		
	}
		

}
